<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Throttle</title>
  <style>
  html, body {
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
  }
  #panel {
    display: inline-block;
    width: 360px;
    height: 360px;
    background: hsl(0, 50%, 50%);
  }
  </style>
</head>
<body>
  <div id="panel"></div>
  <script>
  function throttle(fn, ms = 100) {
    let throttleTimer = null;
    return function(...args) {
      if(!throttleTimer) {
        const ret = fn.apply(this, args);
        throttleTimer = setTimeout(() => {
          throttleTimer = null;
        }, ms);
        return ret;
      }
    }
  }

  const panel = document.getElementById('panel');
  panel.addEventListener('mousemove', throttle((e) => {
    const {x, y} = e;
    e.target.style.background = `linear-gradient(${y}deg, 
      hsl(0, 50%, 50%),
      hsl(${0.5 * x}, 50%, 50%))`;
  }));
  </script>
</body>
</html>